package com.banksystem.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.banksystem.Util.TokenUtil;
import com.banksystem.entity.Money;
import com.banksystem.service.Stjfsrevice;

@Controller
public class stjfController {

	@Autowired
	private Stjfsrevice ser;
	@Autowired
	private TokenUtil tokenUtil;
	
	/*
	 * 添加经费
	 */
	@RequestMapping("addjf")
	public  String addjf(Model model,HttpServletRequest request) {
		String username = tokenUtil.findUsernameBytoken(request);
		model.addAttribute("gname",username);
		return "stjf/addjf";
	}
	/*
	 * 添加经费
	 */
	@RequestMapping("addjfa")
	public String addjfa(String gname,String use,String count,String date,String content){
		ser.addjf(gname, use, count, date, content);
		return "stjf/addjf";
	}
	/*
	 * 社团经费管理
	 */
	@RequestMapping("stjfgl")
	public String stjfgl(HttpServletRequest request,Model model) {
		String gname=tokenUtil.findUsernameBytoken(request);
		List<Money> list;
		list=ser.findMoneyAll(gname);
		model.addAttribute("Moneylist", list);
		return "stjf/stjfgl";
	}
	@RequestMapping("detelemoney")
	public String detelemoney(String id){
		ser.deletemoney(id);
		return "forward:stjfgl.do";
	}
	
	/*
	 * 社团支出统计
	 */
	@RequestMapping("stzctj")
	public String stzctj() {
		return "stjf/stzctj";
	}
	
	/*
	 * 搜索
	 */
	@RequestMapping("seachmoney")
	public @ResponseBody List<Money> seachmember(String seach,HttpServletRequest request){
		String gname=tokenUtil.findUsernameBytoken(request);
		List<Money> list=ser.findmoneyAlllike(seach, gname);
		return list;
	}
}
